using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Emlyn.Website.Users;
using Emlyn.Common.Data.DBUpdater;

public partial class ValidateUser : EmlynPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        DBUpdaterMain.WebsiteCode = "EmlynORegan";

        string luserName = Request.QueryString["user"];
        string lvalidationCode = Request.QueryString["code"];

        if (!String.IsNullOrEmpty(luserName) && !String.IsNullOrEmpty(lvalidationCode))
        {
            Emlyn.Website.Users.User luser = (new UserQuery()).GetUserByUserName(luserName);

            if (luser.ValidationCode.Trim() == lvalidationCode.Trim())
            {
                luser.ValidationCode = String.Empty;
                (new UserMod()).Save(luser);

                System.Web.Security.FormsAuthentication.RedirectFromLoginPage(luser.UserName, false);
            }
        }

        Response.Redirect("default.aspx");
    }
}
